<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

use Illuminate\Support\Facades\DB;

class subscribe extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $art = DB::table('art')->select('art_id', 'title', 'content')
            ->where('is_state', 0)->where('is_del', 1)
            ->whereRaw('YEARWEEK( FROM_UNIXTIME( pubtime, \'%Y-%m-%d\' ) ) = YEARWEEK(now())-3')
            ->orderBy('view', 'desc')->take(1)->get()->toJson();
        return $this->view('home.email.subscribe')->with(['art'=>\GuzzleHttp\json_decode($art,true)]);
    }
}
